package com.whfc.ms.api.emp.service.impl;

import com.whfc.common.result.ListData;
import com.whfc.common.result.PageData;
import com.whfc.emp.dto.*;
import com.whfc.emp.param.*;
import com.whfc.emp.service.AppEmpWarnService;
import com.whfc.emp.service.AppWorkPlanService;
import com.whfc.entity.dto.msg.AppWarnMsgRecDTO;
import com.whfc.fuum.entity.SysUser;
import com.whfc.ms.api.emp.service.MsAppEmpWarnService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.Date;

/**
 * @ClasssName MsAppEmpWarnServiceImpl
 * @Description 人员报警设置
 * @Author hw
 * @Date 2021/1/5 11:38
 * @Version 1.0
 */
@Service
public class MsAppEmpWarnServiceImpl implements MsAppEmpWarnService {

    @DubboReference(interfaceClass = AppEmpWarnService.class, version = "1.0.0")
    private AppEmpWarnService appEmpWarnService;

    @DubboReference(interfaceClass = AppWorkPlanService.class, version = "1.0.0")
    private AppWorkPlanService appWorkPlanService;

    @Override
    public PageData<AppWarnRuleDTO> settingList(Integer deptId, Integer pageNum, Integer pageSize, String keyword, Integer ruleType, Integer enableFlag, Integer warnType) {
        return appEmpWarnService.settingList(deptId, pageNum, pageSize, keyword, ruleType, enableFlag, warnType);
    }

    @Override
    public void setTime(AppWarnSetTimeParam request) {
        appEmpWarnService.setTime(request);
    }

    @Override
    public AppWarnMsgRecDTO userList(Integer ruleId) {
        return appEmpWarnService.userList(ruleId);
    }

    @Override
    public void setUser(AppWarnEmpSetUserParam request) {
        appEmpWarnService.setUser(request);
    }

    @Override
    public PageData<AppWarnEmpRecordDTO> recordList(Integer deptId, Integer pageNum, Integer pageSize, Integer state, Integer ruleType, Date startTime, Date endTime) {
        return appEmpWarnService.recordList(deptId, pageNum, pageSize, state, ruleType, startTime, endTime);
    }

    @Override
    public AppWarnEmpRecordDetailDTO recordDetail(Integer warnId) {
        return appEmpWarnService.recordDetail(warnId);
    }

    @Override
    public void handle(SysUser user, AppWarnHandleParam request) {
        Integer userId = user.getId();
        String userName = user.getNickname();
        String phone = user.getPhone();
        appEmpWarnService.handle(userId, userName, phone, request);
    }

    @Override
    public void batchHandle(WarnBatchHandleParam param) {
        appEmpWarnService.batchHandle(param);
    }

    @Override
    public void del(WarnBatchDelParam param) {
        appEmpWarnService.del(param);
    }

    @Override
    public Integer getWarnNum(Integer deptId, Date startTime, Date endTime) {
        return appEmpWarnService.getWarnNum(Arrays.asList(deptId), startTime, endTime);
    }

    @Override
    public AppWarnEmpRecordNumDTO num(Integer deptId, Integer state, Date startTime, Date endTime) {
        return appEmpWarnService.empWarnNum(deptId, state, startTime, endTime);
    }

    @Override
    public void enable(AppEmpWarnEnableParam request) {
        appEmpWarnService.enable(request);
    }

    @Override
    public void settingAdd(AppEmpWarnAddParam param) {
        appEmpWarnService.settingAdd(param);
    }

    @Override
    public void settingEdit(AppEmpWarnEditParam param) {
        appEmpWarnService.settingEdit(param);
    }

    @Override
    public void settingDel(Integer ruleId) {
        appEmpWarnService.settingDel(ruleId);
    }

    @Override
    public ListData<AppEmpDTO> objectList(Integer ruleId, String empName) {
        return appEmpWarnService.objectList(ruleId, empName);
    }

    @Override
    public ListData<AppEmpDTO> getAllObject(Integer ruleId, String empName) {
        return appEmpWarnService.getAllObject(ruleId, empName);
    }

    @Override
    public void objectAdd(EmpWarnObjectAddParam param) {
        appEmpWarnService.objectAdd(param);
    }

    @Override
    public boolean sendAlarmMessageToWorkPlanGuardians() {
        return appWorkPlanService.sendAlarmMessageToWorkPlanGuardians();
    }
}
